package io.github.simplejy.miodemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import io.github.simplejy.miodemo.R;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tvUpdatePhone; //一键新机
    private SwitchCompat swSaveParam;   //保存参数
    private SwitchCompat swSaveParamToServer;   //保存参数到服务器
    private View currentParam;  //当前参数
    private View historyParam;  //历史参数
    private View selectApplication; //选择程序

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {

        tvUpdatePhone = (TextView) findViewById(R.id.tv_updata_phone);
        swSaveParam = (SwitchCompat) findViewById(R.id.sw_save_param);
        swSaveParamToServer = (SwitchCompat) findViewById(R.id.sw_save_param_to_server);
        currentParam = findViewById(R.id.layout_current_param);
        historyParam = findViewById(R.id.layout_history_param);
        selectApplication = findViewById(R.id.layout_select_application);

        tvUpdatePhone.setOnClickListener(this);
        swSaveParam.setOnClickListener(this);
        swSaveParamToServer.setOnClickListener(this);
        currentParam.setOnClickListener(this);
        historyParam.setOnClickListener(this);
        selectApplication.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.tv_updata_phone:
                showToast("一键新机");
                break;
            case R.id.sw_save_param:
                break;
            case R.id.sw_save_param_to_server:
                break;
            case R.id.layout_current_param:
                Intent intent = new Intent(MainActivity.this, CurrentParamActivity.class);
                startActivity(intent);
                break;
            case R.id.layout_history_param:
                Intent intentHistory = new Intent(MainActivity.this, HistoryParamActivity.class);
                startActivity(intentHistory);
                break;
            case R.id.layout_select_application:
                Intent intentSelcet = new Intent(MainActivity.this, SelectApplicationActivity.class);
                startActivity(intentSelcet);
                break;
        }

    }

    private void showToast(String info) {

        Toast.makeText(this, info, Toast.LENGTH_SHORT).show();

    }
}
